using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SecurityModule.Entity;
using SecurityModule.Web.App_Code;
using SBCommon.Web.UI;
using SecurityModule.Service;
using System.Collections.Generic;
using SBCommon;

namespace SecurityModule.Web.Controls
{
    public partial class UserGroupTree : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            InitializeUI();
        }

        private void InitializeUI()
        {
            if (!IsPostBack)
            {
                InitDropDwonList();
            }
        }

        private void InitDropDwonList()
        {
            //DataBoundControlBuilder.BuildDropDownList<
            DropDownListHelper.FillApplicationItems(ddlUserGroup, true, false);
        }

        private void InitTreeView(List<DataObject> lists)
        {
            //TreeViewHelper.InitTreeView<DataObject>(this.DataObjectTreeView, dt);
            DataBoundControlBuilder.BuildTreeView<DataObject>(UserGroupTreeView, lists);
        }

        protected void ddlUserGroup_SelectedIndexChanged(object sender, EventArgs e)
        {
            string applicationId = ddlUserGroup.SelectedValue;
            DataObjectService service = new DataObjectService();
            //DataSet ds = service.GetAllByApplicationId(ConvertUtil.ToInt32(applicationId));
            //if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
            //{
            //    InitTreeView(ds.Tables[0]);
            //}
            List<DataObject> lists = service.GetAllByApplicationId(ConvertUtil.ToInt32(applicationId));
            InitTreeView(lists);
        }

        protected void UserGroupTreeView_SelectedNodeChanged(object sender, EventArgs e)
        {
        }
    }
}